<?php

namespace app\model\agent;

use app\model\order\StoreOrder;
use app\model\product\sku\StoreProductAttrValue;
use app\model\user\User;
use crmeb\basic\BaseModel;
use crmeb\traits\ModelTrait;

class AgentMoneyLog extends BaseModel
{
    use ModelTrait;

    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 模型名称
     * @var string
     */
    protected $name = 'agent_money_logs';


    public function order()
    {
        return $this->belongsTo(StoreOrder::class, 'order_id', 'id');
    }

    public function attrInfo()
    {
        return $this->belongsTo(StoreProductAttrValue::class, 'product_att_value_unique', 'unique');
    }

    public function agent()
    {
        return $this->belongsTo(User::class, 'user_id', 'uid');
    }

    public function buyer()
    {
        return $this->belongsTo(User::class, 'buyer_uid', 'uid');
    }

    public function relatedLogs()
    {
        return $this->hasMany(AgentMoneyLog::class, 'order_id', 'order_id');
    }

}